<%@ tag language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ attribute name="name"%>
<%@ attribute name="id"%>
<%@ attribute name="dataList"%>
<%@ attribute name="requestUrl"%>
<%
	if (id == null || "".equals(id)) {
		id = UUID.randomUUID().toString();
	}
%>
<select name="<%=name%>" id="<%=id%>">
</select>
<script type="text/javascript">
//required="true"
	var dataList = "<%=dataList%>";
	var requestUrl = "<%=requestUrl%>";
	var name = "<%=name%>";
	var id = "<%=id%>";
	var combo = document.getElementById(id);
	if (dataList != null && dataList != '') {
		dataList = eval("(" + dataList + ")");
		if (requestUrl != null && requestUrl != '') {
			Request.request(requestUrl, {}, function(dataList) {
				var fieldStr = '';
				for ( var i = 0; i < dataList.length; i++) {
					var data = dataList[i];
					fieldStr += '<option value="'+data.id+'">' + data.text
							+ '</option>';
				}
				combo.innerHTML = fieldStr;
			});
		} else {
			var fieldStr = '';
			for ( var i = 0; i < dataList.length; i++) {
				var data = dataList[i];
				fieldStr += '<option value="'+data.id+'">' + data.name
						+ '</option>';
			}
			combo.innerHTML = fieldStr;
		}
	}
</script>